<template>
  <div style="margin-top: 60px;margin-left:450px;width: 300px;height: 500px;border: 0px solid red;" >
    <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="物流类型" prop="logisticstype">
        <el-input v-model="ruleForm.logisticstype"></el-input>
      </el-form-item>

      <el-form-item label="满足率" prop="logsatisfy">
        <el-input v-model="ruleForm.logsatisfy"></el-input>
      </el-form-item>

      <el-form-item label="变动原因" prop="logchange">
        <el-input v-model="ruleForm.logchange"></el-input>
      </el-form-item>

      <el-form-item label="数据变化" prop="shift">
        <el-input v-model="ruleForm.shift"></el-input>
      </el-form-item>

      <el-form-item label="价格" prop="price">
        <el-input v-model="ruleForm.price"></el-input>
      </el-form-item>

      <el-form-item label="价格变化" prop="priceenter">
        <el-input v-model="ruleForm.priceenter"></el-input>
      </el-form-item>

      <el-form-item label="创建时间" prop="creatDate">
        <el-input v-model="ruleForm.creatDate"></el-input>
      </el-form-item>

      <el-form-item label="请审批" prop="state">
        <el-radio-group v-model="ruleForm.state">
          <el-radio :label="2" :value="2">通过</el-radio>
          <el-radio :label="3" :value="3">未通过</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">开始审批</el-button>
        <el-button @click="goback">返回</el-button>
      </el-form-item>
    </el-form>


  </div>

</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        logisticstype: '',
        logsatisfy: '',
        logchange: '',
        shift: '',
        price: '',
        priceenter: "",
        creatDate:"",
        state:"",
      },
    };
  },
  methods: {
    submitForm(formName) {
      const _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(_this.ruleForm)
          axios.put('http://localhost:8081/log/update',_this.ruleForm).then(function (resp){
            _this.$alert(_this.ruleForm.logisticstype + '   审批完成', '', {
              confirmButtonText: '确定',
              callback: action => {
                _this.$router.push('/approvalLog')
              }
            })
          })
        }
      });
    },
    goback(){
      const _this = this
      _this.$router.push("/approvalLog")
    }
  },
  created() {
    const _this = this
    axios.get('http://localhost:8081/log/approv/'+ _this.$route.query.id).then(function (resp){
      _this.ruleForm = resp.data
    })
  }
}
</script>
